<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head lang="en">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no"/>
    <meta name="format-detection" content="telephone=no"/>
    <meta name="format-detection" content="email=no"/>
    <meta charset="UTF-8">
    <script type="text/javascript" th:src="@{${session.baseUrl}+'js/common.js'}"></script>
    <script th:src="@{${session.baseUrl}+'js/jquery.js'}"></script>
    <link th:href="@{${session.baseUrl}+'style/reset.css'}" rel="stylesheet" type="text/css">
    <link th:href="@{${session.baseUrl}+'style/base.css'}" rel="stylesheet" type="text/css">
    <link th:href="@{${session.baseUrl}+'style/header.css'}" rel="stylesheet" type="text/css">
    <link rel="stylesheet" th:href="@{${session.baseUrl}+'style/coupon.css'}"/>
    <link th:href="@{${session.baseUrl}+'style/dialog.css'}" rel="stylesheet" type="text/css">
    <link th:href="@{${session.baseUrl}+'style/global.css'}" rel="stylesheet" type="text/css">
    <script th:src="@{${session.baseUrl}+'js/dialog.js'}"></script>
    <title>领取优惠券</title>
</head>
<body>
<header><span onclick="javascript:history.go(-1)"></span>领取优惠券</header>
<!--<nav>
    <ul class="df jcsb bgwh">
        <li class="tc fx1 active">未使用</li>
        <li class="tc fx1">已使用</li>

    </ul>
</nav>-->
<ul id="content0" class="content">
    <li th:each="ling,iterStat : ${memberProjectList}">

        <div th:onclick="'javascript:lingqu(\''+${ling.id}+'\')'">
            <span th:if="${ling.typee==0}"><span class="f20 wh" th:text="${ling.projectName}"></span><span class="f20 wh">指定优惠券</span></span>
            <p class="money"><span>年化率</span><span th:text="${#numbers.formatDecimal(100*ling.rate,1,2)}+'%'"></span><span th:text="${ling.typee==0}?'指定项目使用':'通用优惠券'"></span></p>
        </div>
    </li>

</ul>
<div th:if="${memberProjectList==null||memberProjectList.size()==0}">
    <img th:src="@{${session.baseUrl}+'\images\zanwu.png'}" style="width: 8.5rem;height:5.2rem;transform: translate(0rem, 0rem);"/>
</div>
<!--<ul id="content1" class="content" style="display: none;">
    <li th:each="couyes,iterStat : ${listYes}">
        <div>
            <h1 class="f28 wh pl10">优惠券</h1>
            <p class="money"><span>利率</span><span th:text="${#numbers.formatDecimal(100*couyes.rate,1,2)}+'%'"></span><span th:text="${couyes.typee==0}?'指定项目使用':'通用优惠券'"></span></p>
            <span th:if="${couyes.typee==0}"><span class="f20 wh" th:text="${couyes.projectName}"></span><span class="f20 wh">指定优惠券</span></span>
        </div>
    </li>

</ul>-->

<!--<script>
    $(function(){
       $("nav ul li").each(function(index,val){
           $(val).click(function(){
               $(this).addClass("active").siblings().removeClass("active");
               $("#content"+index).show().siblings(".content").hide();
           });

       });
    });
</script>-->

<script type="text/javascript" th:inline="javascript">
    //<![CDATA[
    var basePath = /*[[${#httpServletRequest.getScheme() + "://" + #httpServletRequest.getServerName() + ":" + #httpServletRequest.getServerPort() + #httpServletRequest.getContextPath()}]]*/;

    function lingqu(obj) {
        $.ajax({
            url: "/wap/ling",
            contentType: 'application/json',
            type: "get",
            dataType: "json",
            data: {
                memberId: [[${session.memberId}]],
                lingquId:obj
            },
            success: function (e) {
                console.log(e);
                if (e.data==true) {
                    $('body').dailog({type: 'success', title: '领取', discription: '领取成功'});
                    self.setInterval(function () {
                        window.location.href=basePath+"/wap/lingqu.html";
                    }, 2000) //这里3000代表3秒
                }else if(e.data==false){
                    $('body').dailog({type: 'warning', title: '领取', discription: '领取失败'});
                    self.setInterval(function () {
                        location.reload();
                    }, 2000)
                }else if(e.data=="you"){
                    $('body').dailog({type: 'warning', title: '领取', discription: '请勿重复领取！'});
                    self.setInterval(function () {
                        location.reload();
                    }, 2000)
                }else if(e.data=="nologin"){
                    $('body').dailog({type: 'warning', title: '未登录', discription: '请您先登录'});
                    self.setInterval(function () {
                        location.reload();
                    }, 3000)
                }

            }
        })
    }

    //]]>
</script>
</body>
</html>